function showCenterDiv(e)
{
  var elem = document.getElementById(e);

	var eHeight = document.defaultView.getComputedStyle(elem,"").getPropertyValue("height");
	var eWidth = document.defaultView.getComputedStyle(elem,"").getPropertyValue("width");

	eHeight = eHeight.substring(0,eHeight.length-2);
	eWidth = eWidth.substring(0,eWidth.length-2);

  var leftPosition = window.innerWidth - eWidth;
  var topPosition = window.innerHeight - eHeight;
	
  leftPosition = (leftPosition < 0) ? 0 : leftPosition/2;
  topPosition  = (topPosition < 0)  ? 0 : topPosition /2;
  
  document.getElementById(e).style.left=leftPosition+'px';
  document.getElementById(e).style.top=topPosition+'px';
  document.getElementById(e).style.display='';
} 

function showProgressDiv(dvi)
{
  var elem = document.getElementById(dvi);

	var eHeight = document.defaultView.getComputedStyle(elem,"").getPropertyValue("height");
	var eWidth = document.defaultView.getComputedStyle(elem,"").getPropertyValue("width");

	eHeight = eHeight.substring(0,eHeight.length-2);
	eWidth = eWidth.substring(0,eWidth.length-2);

  var leftPosition = window.innerWidth - eWidth;
  var topPosition = window.innerHeight - eHeight;
	
  leftPosition = (leftPosition < 0) ? 0 : leftPosition;
  topPosition  = (topPosition < 0)  ? 0 : topPosition;
  
  elem.style.left=leftPosition+'px';
  elem.style.top=topPosition+'px';
  elem.style.display='';
} 
/*
function hideDivs(dn,show)
{

	if (show != true) show = false;
	
	var x = document.getElementsByTagName('div');
	
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == dn) {
			if (show) x[i].style.visibility = 'visible';
			else x[i].style.visibility = 'hidden';
		}		
	}	

}
*/

function hideDivs(dn,show)
{

	if (show != true) show = false;
	
	var x = document.getElementById(dn);
	var elem = document.getElementById('blocker');
	
	
	if (!show) {
		var eHeight = document.defaultView.getComputedStyle(x,"").getPropertyValue("height");
		var eWidth = document.defaultView.getComputedStyle(x,"").getPropertyValue("width");
		var eTop = document.defaultView.getComputedStyle(x,"").getPropertyValue("top");
		var eLeft = document.defaultView.getComputedStyle(x,"").getPropertyValue("left");

		elem.style.height=eHeight;
		elem.style.width=eWidth;
		elem.style.top=eTop;
		elem.style.left=eLeft;
		elem.style.display='';
	} else {
		elem.style.display='none';
	}
}
//editelement
//function updateRow(rowId,fName,cStatus){
/*
  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY)
  {
   posx = e.pageX;
   posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
   posx = e.clientX;
   posy = e.clientY;
  }
  if (posy-150<0) {posy += 70;} else {posy += -150;}
  if (posx+400>window.innerWidth) {posx = window.innerWidth - 430;} 
  else if (posx-100<0) {posx = 0;} else {posx += -100;}

  //var elem = document.getElementById("row" + rowId);
  //alert(elem.offsetWidth);
  //alert(document.defaultView.getComputedStyle(elem,"").getPropertyValue("width"));
	
	/*
   var eHeight = document.defaultView.getComputedStyle(elem,"").getPropertyValue("height");
	var eWidth = document.defaultView.getComputedStyle(elem,"").getPropertyValue("width");

	eHeight = eHeight.substring(0,eHeight.length-2);
	eWidth = eWidth.substring(0,eWidth.length-2);

  var leftPosition = posy;
  var topPosition = posx;

  var e = document.getElementById("editelement");
  e.style.left=leftPosition+'px';
  e.style.top=topPosition+'px';
  e.style.display='';
  */
 //}
 
function updateFile(e,frm, rowId,fName,cStatus,cSt){
	var coordinates = getAnPos("row" + rowId); 
	
	var el = document.getElementById("editelement");
	   
	   /* POSITION */
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX;
		posy = e.clientY;
	}
	if (posy-150<0) {posy += 70;} else {posy += -150;}
	if (posx+400>window.innerWidth) {posx = window.innerWidth - 430;} 
	else if (posx-100<0) {posx = 0;} else {posx += -100;}
	   
	el.style.left=posx+'px';
	el.style.top=posy+'px';
	
	   /* EN POS */
	var forma = document.getElementById(frm);
	   
	forma.filename.value = fName;
	forma.id.value=rowId;
	forma.fstamp.value=cSt;
	forma.newstatus.value=cStatus;
	forma.comment.value="";
	   /*
	for (i=0;i<status.length;i++) {
		if (status[i].value == cStatus) {
			status.selectedIndex = i;
		}   		
	}
	*/
	//hideDivs('hideme',false);   
	el.style.display='';   
}
 
function openDiv(e,dv){

	var el = document.getElementById(dv);
   
   /* POSITION */
  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY)
  {
   posx = e.pageX;
   posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
   posx = e.clientX;
   posy = e.clientY;
  }
  if (posy-150<0) {posy += 70;} else {posy += -150;}
  if (posx+400>window.innerWidth) {posx = window.innerWidth - 430;} 
  else if (posx-100<0) {posx = 0;} else {posx += -100;}
   
  el.style.left=posx+'px';
  el.style.top=posy+'px';

   /* EN POS */
	el.style.display='';   
 }
 
function closeForm(dv){
	//hideDivs('hideme',true);   
	var el = document.getElementById(dv);
   el.style.display='none';
 }
 
function getEventPosition(e) {
    /* POSITION */
  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY)
  {
   posx = e.pageX;
   posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
   posx = e.clientX;
   posy = e.clientY;
  }
  /*
  if (posy-150<0) {posy += 70;} else {posy += -150;}
  if (posx+400>window.innerWidth) {posx = window.innerWidth - 430;} 
  else if (posx-100<0) {posx = 0;} else {posx += -100;}
   */
   var coordinates=new Object();
   coordinates.x=posx;
   coordinates.y=posy;
   
   return coordinates;
   /* EN POS */
 
 }
 
 function getDivPosition(e) {
    var coordinates = getEventPosition(e);
   coordinates.x=posx+'px';
   coordinates.y=posy+'px';
   
   return coordinates;
 
 }
 function getAnPos(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnPos_getPageOffsetLeft(document.all[anchorname]);
		y=AnPos_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnPos_getPageOffsetLeft(o);
		y=AnPos_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnPos_getPageOffsetLeft(document.all[anchorname]);
		y=AnPos_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}
	
	function AnPos_getPageOffsetLeft (el) {
		var ol=el.offsetLeft;
		while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
		return ol;
	}
	function AnPos_getPageOffsetTop (el) {
		var ot=el.offsetTop;
		while((el=el.offsetParent) != null) { ot += el.offsetTop; }
		return ot;
	}
/*
 function messageForm(e,action,redirect,mail){
	
	var el = document.getElementById("messagediv");
   
   // POSITION 
  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY)
  {
   posx = e.pageX;
   posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
   posx = e.clientX;
   posy = e.clientY;
  }
  if (posy-150<0) {posy += 70;} else {posy += -150;}
  if (posx+400>window.innerWidth) {posx = window.innerWidth - 430;} 
  else if (posx-100<0) {posx = 0;} else {posx += -100;}
   
   el.style.left=posx+'px';
   el.style.top=posy+'px';

   // EN POS 
	var fmail = document.getElementById("mail");
  var fredirect = document.getElementById("redirect");
  var faction = document.getElementById("action");
   
  fmail.value = mail;
  fredirect.value=redirect;
  faction.value=action;
   
	el.style.display='';   
 }
 */
 function setAction(form,act) {
 
 	var frm = document.getElementById(form);
 	frm.action.value = act;
 	frm.submit();
 		
 }
 
 function getfile(url) {
 	window.open(url);	
 }
 
function checkAll(f) {
	var l = document.getElementsByName(f);
	for (i=0;i<l.length;i++) {
		l[i].checked=true;
	}
}

function uncheckAll(f) {
	var l = document.getElementsByName(f);
	for (i=0;i<l.length;i++) {
		l[i].checked=false;
	}
}

function countCheckedElements(name) {
	var lista = document.getElementsByName(name);
	var count=0;
	for (i=0;i<lista.length;i++) {
		if (lista[i].checked) count++;
	}
	return count;
}

function getCheckedElements(name) {
	var lista = document.getElementsByName(name);
	var el="";
	for (i=0;i<lista.length;i++) {
		if (lista[i].checked) {
			if (el=="") el=lista[i].value;
			else el += ";"+lista[i].value;
		}
	}
	return el;
}

function checkFile(f) {
	if (f.lastIndexOf(".tar.gz")<0 && f.lastIndexOf(".tgz")<0 && f.lastIndexOf(".tar")<0) {
		return false;
	}	
	return true;
}

function processForm(form) {
	var forma = document.forms[form];
	forma.submit();
}